import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useContactStore = defineStore('contact', () => {
  // 联系人
  const contacts = ref([
    {
      id: 1,
      name: 'user1',
      avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
      desc: '在线',
    },
    {
      id: 2,
      name: 'user2',
      avatar: '',
      desc: '离线',
    },
    {
      id: 3,
      name: '小明',
      avatar: '',
      desc: '忙碌',
    },
  ])

  // 当前选中
  const selectedId = ref(contacts.value[0].id)

  // 修改当前选中
  function selectContact(id: number) {
    selectedId.value = id
  }

  return { contacts, selectedId, selectContact }
})
